package com.glc.hms.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.glc.hms.common.util.DateTimeUtils;
import com.glc.hms.system.dao.SysLogMapper;
import com.glc.hms.system.entity.SysLog;
import com.glc.hms.system.service.ISysLogService;
import com.google.common.collect.Maps;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.Map;

/**
 * <p>
 * 系统日志 服务实现类
 * </p>
 *
 * @author Santa
 * @since 2019-11-20
 */
@Service
public class SysLogServiceImpl extends ServiceImpl<SysLogMapper, SysLog> implements ISysLogService {

    @Autowired
    private SysLogMapper sysLogMapper;

    /**
     * 查询访问量
     * @return
     */
    @Override
    public Map<String, Integer> queryLoginNum(){
        //查询今日访问总量
        Integer today = sysLogMapper.queryLoginNum(DateTimeUtils.convertDateToString(new Date()));
        Integer total = sysLogMapper.queryLoginNum(null);
        Integer totalIp = sysLogMapper.totalIp();
        Map<String, Integer> map = Maps.newHashMap();
        map.put("today",today);
        map.put("total",total);
        map.put("totalIp",totalIp);
        return map;
    }

}
